Data Processing Method and Apparatus

ABSTRACT

A data processing method and apparatus, where one or more applications run in an operating system of a first device, there is a plurality of paths between the first device and a second device, and the paths correspond to the one or more applications. In a data receiving process, the one or more applications obtain data on the paths through a system call, and further obtain data in a plurality of packets from at least one path. In a data sending process, the one or more applications distribute data to corresponding paths through a system call.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Patent ApplicationNo. PCT/CN2020/078965 filed on Mar. 12, 2020, which claims priority toChinese Patent Application No. 201910200157.1 filed on Mar. 15, 2019.The disclosures of the aforementioned applications are herebyincorporated by reference in their entireties.

TECHNICAL FIELD

Embodiments of this application relate to the field of computertechnologies, and in particular, to a data processing method andapparatus.

BACKGROUND

Information is often exchanged between applications of a computer. Theapplication usually runs in an operating system of a device such as aterminal or a server, for example, runs in a user mode of the operatingsystem. Therefore, the application needs to trap into a kernel mode, andread data from kernel space corresponding to the kernel mode or copyto-be-sent data to the kernel space.

The application may be described using a software system architecturesuch as a client/server (C/S). In this architecture, the client and theserver are applications. An application serving as the client requests aservice, and an application serving as the server provides the servicefor the application serving as the client. In some scenarios, the clientand the server run on different devices. For example, if an applicationruns on a terminal, the application is a client, or if an applicationruns on a server, the application is a server. The client and the serverexchange data by establishing a connection. One connection may include aplurality of paths. This connection is referred to as a multipathconnection, and a corresponding technology is referred to as a multipathtransmission technology. Alternatively, one connection corresponds toone path, for example, a common Transmission Control Protocol (TCP)connection, a User Datagram Protocol (UDP) connection, or a Quick UDPInternet Connections (QUIC). These paths may transmit data based on aWi-Fi network, a cellular network, BLUETOOTH, or the like. For example,the client and the server use the multipath transmission technology. Aplurality of subflows are established between the client and the server.Each subflow corresponds to one path, or each subflow corresponds to oneconnection. Each path (or connection) corresponds to one pair of socketdescriptors, where one socket descriptor is located on a device on whichthe client is located, and the other socket descriptor is located on adevice on which the server is located.

Regardless of receiving data or sending data, an application needs toexecute a system call to process the data. For example, after anoperating system of a device on which the application is locatedreceives one packet over one path corresponding to the application, theapplication needs to execute one system call to read data using a socketdescriptor corresponding to the path. Correspondingly, each time theapplication sends data over one path, the application also needs toexecute one system call, to indicate, through a socket descriptorcorresponding to the path, to-be-sent data to a protocol stack below anapplication layer. However, one system call generates large overheads.In an actual application scenario, it is very common that oneapplication frequently receives and sends data, one application receivesand sends data over a plurality of paths, and a plurality ofapplications run on one device. Therefore, in a process in which onedevice exchanges data with another device, frequent system calls occupymany resources. This causes high central processing unit (CPU)utilization of the device and increases power consumption.

SUMMARY

Embodiments of this application provide a data processing method andapparatus, to reduce CPU utilization and power consumption of a deviceby reducing a quantity of system calls.

According to a first aspect, an embodiment of this application providesa data processing method, where the method is used to process data on aplurality of paths, the plurality of paths are paths between a firstdevice and a second device, the plurality of paths correspond to one ormore applications, the one or more applications run in an operatingsystem of the first device, and the method includes receiving, by theoperating system of the first device, packets on the plurality of paths,where the packets are from the second device, and after the operatingsystem of the first device receives the packets on the plurality ofpaths, obtaining, by the one or more applications through only onesystem call, data respectively corresponding to the one or moreapplications from data carried in the packets. In this solution, theapplication running in the operating system of the first device mayobtain the data on the plurality of paths through only one system call,and may further obtain, for the plurality of paths, data in a pluralityof packets (depending on an amount of data that is received by theplurality of paths in a kernel when the system call is being executed)from at least one path through the system call such that a quantity ofsystem calls is small, and overheads are small. Therefore, CPUutilization and power consumption of the first device can be reduced. Inaddition, because data in cache space indicated by a plurality of socketdescriptors can be simultaneously read through only one system call,data reading efficiency can be improved.

In a feasible design, obtaining, by the one or more applications throughonly one system call, data respectively corresponding to the one or moreapplications from data carried in the packets includes obtaining, by theone or more applications by calling a receive function only once, thedata respectively corresponding to the one or more applications from thedata carried in the packets, where the receive function is a system callinterface, and the receive function is used to poll socket descriptorscorresponding to two or more paths, to obtain data indicated by thesocket descriptors corresponding to the two or more paths. In thismethod, the one or more applications running in the operating system ofthe first device manage each socket such that the receive function pollsthe socket descriptors, to read the data in the packets from cache spaceindicated by the socket descriptors.

In a feasible design, input of the receive function includes socketdescriptors respectively corresponding to the plurality of paths. Inthis solution, the one or more applications running in the operatingsystem of the first device input the socket descriptors respectivelycorresponding to the plurality of paths to the receive function suchthat the receive function polls the socket descriptors, to read the datain the packets from cache space indicated by the socket descriptors.

In a feasible design, the one or more applications execute one systemcall to poll the socket descriptors respectively corresponding to theplurality of paths, and the operating system of the first device sendsfirst acknowledgement information to the one or more applications, wherethe first acknowledgement information indicates that the operatingsystem acknowledges that the data respectively corresponding to the oneor more applications has been obtained by the one or more applications.For example, the one or more applications running in the operatingsystem of the first device execute the system call to read data fromcache space corresponding to a socket descriptor of each path, and theoperating system of the first device detects whether data in cache spaceindicated by each socket descriptor has been successfully read, andgenerates acknowledgment information for each socket descriptor.Acknowledgement information of all the socket descriptors forms thefirst acknowledgment information. Acknowledgement information of eachsocket descriptor is used to indicate whether data in cache spaceindicated by the socket descriptor has been successfully read.

In a feasible design, at least two of the plurality of paths belong to asame multipath connection. In this solution, because at least two of theplurality of paths belong to a same multipath (MP) connection, in an MPconnection implementation scenario, the application can read, throughonly one system call, data from cache space indicated by socketdescriptors of a plurality of paths included in the MP connection.

In a feasible design, the packets on the plurality of paths that arereceived by the operating system of the first device include at leasttwo packets from a same path. In this solution, there may be a pluralityof packets from a same path such that when reading, through one systemcall, data from cache space indicated by the socket descriptors of theplurality of paths, the application can read data in at least twopackets from cache space indicated by a same socket descriptor.

In a feasible design, the one or more applications may bind the socketdescriptors of the plurality of paths together and transfer the socketdescriptors to the receive function as an array such that the receivefunction polls the socket descriptors in the array, to read the data inthe packets from the cache space indicated by the socket descriptors.Certainly, in addition to the array, another data structure may be usedto enable the receive function to learn the socket descriptors. Foranother example, the socket descriptors of the plurality of paths aresorted in advance, and the receive function reads, based on an order,data from the cache space indicated by the socket descriptors.

In a feasible design, the plurality of paths respectively corresponds todifferent socket descriptors.

According to a second aspect, an embodiment of this application providesa data processing method, where the method is used to process data on aplurality of paths, the plurality of paths are paths between a firstdevice and a second device, the plurality of paths corresponds to one ormore applications, the one or more applications run in an operatingsystem of the first device, and the method includes correspondinglydistributing, by the one or more applications, data of the one or moreapplications to the plurality of paths through only one system call, andsending, by the operating system of the first device, the data to thesecond device over the plurality of paths. In this solution, the one ormore applications running in the operating system of the first devicemay distribute the data of the one or more applications to correspondingpaths through only one system call such that a quantity of system callsis small, and overheads are small. Therefore, CPU utilization and powerconsumption of the first device can be reduced. In addition, becausedata can be simultaneously written, through only one system call, tocache space indicated by a plurality of socket descriptors, data writingefficiency can be improved.

In a feasible design, correspondingly distributing, by the one or moreapplications, data of the one or more applications to the plurality ofpaths through only one system call includes correspondinglydistributing, by the one or more applications, the data of the one ormore applications to the plurality of paths by calling a transmitfunction only once, where the transmit function is a system callinterface, and the transmit function is used to poll socket descriptorscorresponding to two or more paths, to distribute the data to cachespace indicated by the socket descriptors corresponding to the two ormore paths. In this solution, the one or more applications running inthe operating system of the first device manage each socket such thatthe transmit function polls the socket descriptors, to write the data ofthe one or more applications to cache space indicated by the socketdescriptors.

In a feasible design, input of the transmit function includes socketdescriptors respectively corresponding to the plurality of paths. Inthis solution, the one or more applications running in the operatingsystem of the first device input the socket descriptors respectivelycorresponding to the plurality of paths to the transmit function suchthat the transmit function polls the socket descriptors, to write thedata of the one or more applications to cache space indicated by thesocket descriptors.

In a feasible design, the operating system of the first device sendssecond acknowledgment information to the one or more applications, wherethe second acknowledgment information indicates that the operatingsystem acknowledges that the data respectively corresponding to the oneor more applications has been written to the cache space indicated bythe socket descriptors respectively corresponding to the plurality ofpaths. In this solution, the operating system of the first device sendsthe second acknowledgment information to the one or more applications,and the second acknowledgment information indicates that the operatingsystem determines whether the data respectively corresponding to the oneor more applications has been distributed to the paths such that theoperating system of the first device manages each application.

In a feasible design, at least two of the plurality of paths belong to asame multipath connection. In this solution, because at least two of theplurality of paths belong to a same MP connection, in an MP connectionimplementation scenario, the application can write, through only onesystem call, data to cache space indicated by socket descriptors of aplurality of paths included in the MP connection.

According to a third aspect, an embodiment of this application providesa data processing apparatus, where the apparatus is configured toprocess data on a plurality of paths, the plurality of paths are pathsbetween a first device and a second device, the plurality of pathscorrespond to one or more applications, the one or more applications runin an operating system of the first device, and the apparatus includesan operating system configured to receive packets on the plurality ofpaths, where the packets are from the second device, and an applicationconfigured to, after the operating system receives the packets on theplurality of paths, obtain, through only one system call, datarespectively corresponding to the one or more applications from datacarried in the packets.

In a feasible design, the application is configured to obtain, bycalling a receive function only once, the data respectivelycorresponding to the one or more applications from the data carried inthe packets, where the receive function is a system call interface, andthe receive function is used to poll socket descriptors corresponding totwo or more paths, to obtain data indicated by the socket descriptorscorresponding to the two or more paths.

In a feasible design, input of the receive function includes socketdescriptors respectively corresponding to the plurality of paths.

In a feasible design, the operating system is further configured to sendfirst acknowledgment information to the one or more applications, wherethe first acknowledgment information indicates that the operating systemacknowledges that the data respectively corresponding to the one or moreapplications has been obtained by the one or more applications.

In a feasible design, at least two of the plurality of paths belong to asame multipath connection.

In a feasible design, the packets on the plurality of paths that arereceived by the operating system of the first device include at leasttwo packets from a same path.

According to a fourth aspect, an embodiment of the present disclosureprovides a data processing apparatus, where the apparatus is configuredto process data on a plurality of paths, the plurality of paths arepaths between a first device and a second device, the plurality of pathscorrespond to one or more applications, the one or more applications runin an operating system of the first device, and the apparatus includesan application configured to correspondingly distribute data of the oneor more applications to the plurality of paths through only one systemcall, and an application system configured to send the data to thesecond device over the plurality of paths.

In a feasible design, the application is configured to correspondinglydistribute the respective data of the one or more applications to theplurality of paths by calling a transmit function only once, where thetransmit function is a system call interface, and the transmit functionis used to poll socket descriptors corresponding to two or more paths,to distribute the data to cache space indicated by the socketdescriptors corresponding to the two or more paths.

In a feasible design, input of the transmit function includes socketdescriptors respectively corresponding to the plurality of paths.

In a feasible design, the operating system is further configured to sendsecond acknowledgment information to the one or more applications, wherethe second acknowledgment information indicates that the operatingsystem acknowledges that the data respectively corresponding to the oneor more applications has been written to cache space indicated by thesocket descriptors respectively corresponding to the plurality of paths.

In a feasible design, at least two of the plurality of paths belong to asame multipath connection.

According to a fifth aspect, an embodiment of this application providesa computer program product that includes an instruction, and when theinstruction is run on a processor, the processor is enabled to performthe method in the first aspect or the possible implementations of thefirst aspect.

According to a sixth aspect, an embodiment of this application providesa computer program product that includes an instruction, and when theinstruction is run on a processor, the processor is enabled to performthe method in the second aspect or the possible implementations of thesecond aspect.

According to a seventh aspect, an embodiment of this applicationprovides a computer-readable storage medium, the computer-readablestorage medium stores an instruction, and when the instruction is run ona processor, the processor is enabled to perform the method in the firstaspect or the possible implementations of the first aspect.

According to an eighth aspect, an embodiment of this applicationprovides a computer-readable storage medium, the computer-readablestorage medium stores an instruction, and when the instruction is run ona processor, the processor is enabled to perform the method in thesecond aspect or the possible implementations of the second aspect.

Based on the data processing method and apparatus provided in theembodiments of this application, the one or more applications run in theoperating system of the first device, there are the plurality of pathsbetween the first device and the second device, and the plurality ofpaths correspond to the one or more applications running in theoperating system of the first device. In a data receiving process, theapplication running in the operating system of the first device mayobtain the data on the plurality of paths through only one system call,and may further obtain, for the plurality of paths, the data in theplurality of packets from at least one path through the system call. Ina data sending process, the data of the one or more applications runningin the operating system of the first device may distribute the data ofthe one or more applications to corresponding paths through only onesystem call. It may be learned that in the data receiving process or thedata sending process, a quantity of system calls in this solution issmall, and overheads are small. Therefore, CPU utilization and powerconsumption of the first device can be reduced. In addition, becausedata in cache space indicated by a plurality of socket descriptors canbe simultaneously read through only one system call, data readingefficiency can be improved.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1A is a schematic diagram of a process in which an applicationreceives data;

FIG. 1B is a schematic diagram of another process in which anapplication receives data;

FIG. 2 is a schematic diagram of a network architecture to which anembodiment of this application is applicable;

FIG. 3 is a flowchart of a data processing method according to anembodiment of this application;

FIG. 4 is a flowchart of polling, by a receive function, a socketdescriptor of each path in a data processing method according to anembodiment of this application;

FIG. 5 is a schematic diagram of receiving data by an application in adata processing method according to an embodiment of this application;

FIG. 6 is a flowchart of another data processing method according to anembodiment of this application;

FIG. 7 is a schematic structural diagram of a data processing apparatusaccording to an embodiment of this application; and

FIG. 8 is a schematic structural diagram of a data processing apparatusaccording to an embodiment of this application.

DESCRIPTION OF EMBODIMENTS

Generally, applications on two devices may exchange data by establishingone or more paths.

A terminal and a server are used as an example. An application runningon the terminal is referred to as a client, and an application runningon a server is referred to as a server. The client and the serverexchange data by establishing a plurality of paths. In a data exchangeprocess, for example, an application is a client on the terminal. In adata receiving process, after data arrives at the terminal, for example,in a kernel mode of an operating system of the terminal, the clientneeds to execute a system call to read data from the kernel mode, forexample, cache space in the kernel mode. When the client corresponds toa relatively large quantity of paths, the client needs to execute asystem call for each path, or when the client corresponds to arelatively small quantity of paths, but a data amount on a same path isrelatively large, the client also needs to execute a plurality of systemcalls. Similarly, in a data sending process, the client needs to executea system call to write data to the kernel mode of the operating systemof the terminal, and then can send the data to the server, and aquantity of system calls is related to a quantity of paths correspondingto the client and a data amount on each path. However, relatively largeoverheads are caused when one system call is executed, and hugeoverheads are definitely caused when a plurality of system calls areexecuted. The following describes a reason why overheads are caused whenone system call is executed.

For example, the client communicates with the server using a commonInternet protocol, and the protocol is not implemented by anapplication, but is implemented by an operating system. A terminal isused as an example. A client on the terminal performs communicationusing an application interface calling protocol defined by an operatingsystem of the terminal, for example, a Berkeley Software Distribution(BSD) socket application programming interface (API). Generally, theoperating system has separate process context, and the operating systemusually has two modes: a user mode and a kernel mode. All core servicessuch as a device driver, resource management, and a network protocolthat are provided by the operating system run in the kernel mode, andthe application runs in the user mode. Virtual addresses managed by theoperating system are classified into kernel-mode space and user-modespace. Such classification has significant features in terms of securityand fault tolerance, and also simplifies application development. If theclient needs to access an operating system (OS) service or exchange databetween kernel space and application space, the client needs to use asystem call. To execute the system call, control rights need to betransferred from user space to the kernel space. Specific details dependon implementation of the operating system and a CPU architectureinstruction set, and may involve saving of an execution status,parameter calculation, interruption generation, and the like. Therefore,execution of the application may be interrupted, a cache may berefreshed, and the like. Therefore, huge overheads are generated whenone system call is executed. That the application receives data is usedas an example below to describe how the client executes the system call.

FIG. 1A is a schematic diagram of a process in which an applicationreceives data. Referring to FIG. 1a , a dotted-line box in the figureshows an operating system of a terminal. An application 1, anapplication 2, and an application 3 run in the operating system of theterminal, and respectively correspond to three paths. The three pathseach correspond to one socket descriptor on the terminal: a socketdescriptor 1 (S1), a socket descriptor 2 (S2), and a socket descriptor 3(S3). After a packet 1 sent by a server over a path 1 arrives at theterminal, the packet does not directly arrive at an application at anapplication layer, but is stored below the application layer, forexample, cache space indicated by S1 in kernel space. Similarly, apacket 2 and a packet 3 that are sent by the server over a path 2 arriveat the terminal, and are stored in cache space indicated by S2, and apacket 4 and a packet 5 that are sent by the server over a path 3 arriveat the terminal, and are stored in cache space indicated by S3. Eachtime a packet arrives at the terminal over a path, the terminal triggersthe application at the application layer to execute a system call toread the packet from cache space indicated by a socket descriptor of thepath. For example, if the packet 1 to the packet 5 arrive at theterminal successively, the application executes a first system call toread the packet 1 from the cache space indicated by S1, the applicationexecutes a second system call to read the packet 2 from the cache spaceindicated by S2, the application executes a third system call to readthe packet 3 from the cache space indicated by S2, the applicationexecutes a fourth system call to read the packet 4 from the cache spaceindicated by S3, and the application executes a fifth system call toread the packet 5 from the cache space indicated by S3. In this process,five system calls are executed in total.

To avoid high CPU utilization and high power consumption of the terminalthat are caused due to an excessive quantity of system calls, it isconsidered to execute one system call to read two or more packets. Forexample, FIG. 1B is a schematic diagram of another process in which anapplication receives data.

Referring to FIG. 1B, after arriving at the terminal, the packet 1 tothe packet 5 that are sent by the server are separately stored in thecache space indicated by S1, S2, and S3. It is assumed that the packet 1to the packet 5 arrive at the terminal successively, a time intervalbetween receiving the packet 2 and the packet 3 over the path 2 is smallenough, and a time interval between receiving the packet 4 and thepacket 5 over the path 3 by the terminal is small enough. Theapplication executes a first system call to read the packet 1 from thecache space indicated by S1, executes a second system call to read thepacket 2 and the packet 3 from the cache space indicated by S2, andexecutes a third system call to read the packet 4 and the packet 5 fromthe cache space indicated by S3. In this process, three system calls areexecuted in total. In this process, a time interval between a pluralityof packets read during one system call needs to be small enough.

In the foregoing manner of executing one system call to read a pluralityof packets, a quantity of system calls can be reduced to some extent.However, if a time interval of packets on a path is not small enough, aplurality of packets cannot be read if one system call is executed forthe path, and finally, a plurality of system calls still need to beexecuted to read the plurality of packets. A typical scenario is a cloudscenario. In this scenario, an application runs on the terminal,bandwidth from the terminal to a cloud server is generally relativelysmall, and a throughput is not very high. A plurality of packets cannotbe read if one system call is executed for one path, and consequently,an objective of reducing CPU utilization and power consumption of theterminal by reducing a quantity of system calls cannot be achieved.

In view of this, an embodiment of this application provides a dataprocessing method, to reduce CPU utilization and power consumption of adevice by reducing a quantity of system calls.

FIG. 2 is a schematic diagram of a network architecture to which anembodiment of this application is applicable. Referring to FIG. 2, thearchitecture includes at least one first device, a second device, accessnodes of different networks, and the like. The first device is, forexample, a user equipment (UE), a handheld terminal, a notebookcomputer, a subscriber unit, a cellular phone, a smartphone, a wirelessdata card, a personal digital assistant (PDA) computer, a tabletcomputer, a wireless modem, a handheld device, a laptop computer, acordless phone or a wireless local loop (WLL) station, a machine typecommunication (MTC) terminal, or another device that can access anetwork. The first device communicates with the access node using an airinterface technology. One or more applications run on the first device.

The second device may be, for example, a server such as a service serveror a proxy server, and may provide a service for the one or moreapplications running on the first device. The one or more applicationson the first device may be referred to as a client, and the serviceprovided by the second device may be referred to as a server.

The access node is an access node of a wireless network. The access nodemay be an access point (AP) of a wireless Wi-Fi network, a router, anaccess point of a Worldwide Interoperability for Microwave Access(WiMAX) network, a base station of a wireless cellular mobile network,or the like. A type of the wireless network and a specific form of theaccess node of the wireless network are not limited in the presentdisclosure. In addition, wireless networks of a same type are accessnodes that belong to the wireless Wi-Fi network or the WIMAX network, oraccess nodes that belong to the wireless cellular network such as asecond generation (2G) network, a third generation (3G) network, afourth generation (4G) network, or a fifth generation (5G) network.

Referring to FIG. 2, in this embodiment of this application, both thefirst device and the second device support Wi-Fi and the cellularnetwork. One or more applications run in an operating system of thefirst device, and the second device is configured to provide a servicefor the one or more applications running on the first device. The firstdevice and the second device may exchange data using a multipathtransmission technology and/or a single-path transmission technology.

When the one or more applications of the first device exchange data withthe second device using the multipath transmission technology, oneconnection established between the two devices may include a pluralityof paths. One MP connection is established based on the Wi-Fi networkand the cellular network. The MP connection includes four paths. Asshown by dotted lines in FIG. 2, the MP connection includes a path 1, apath 2, a path 3, and a path 4. The path 1 and the path 2 transmit databased on the cellular network, and the path 3 and the path 4 transmitdata based on the Wi-Fi network.

When the one or more applications of the first device exchange data withthe second device using the single-path transmission technology, oneconnection established between the two devices includes only one path.For example, the path is a path 5 or a path 6 shown by a solid line inthe figure, the path 5 transmits data based on the cellular network, andthe path 6 transmits data based on the Wi-Fi network. The single-pathtransmission technology may use a plurality of transmission protocols,such as a TCP, a UDP, and a QUIC.

Referring to FIG. 2, in this embodiment of this application, the firstdevice may receive a packet from the second device over the foregoingpath (including at least one of the paths of the MP connection and thepath of the single-path transmission technology), and data in the packetis data corresponding to the one or more applications running on thefirst device. Alternatively, the first device may package datacorresponding to the one or more applications into a packet, and sendthe packet to the second device over the foregoing path.

It should be noted that, although the network architecture in thisembodiment of this application is described in detail above using anapplication running on the first device as a client and a serviceprovided on the second device as a server, this is not limited in thisembodiment of this application. For example, in another feasibleimplementation, the first device may also be a server, and the seconddevice may be a terminal.

Some names in the embodiments of this application are explained anddescribed below.

A and/or B indicates A and B, or A or B.

Data processing may be data processing in a data receiving process, ormay be data processing in a data sending process. In the data receivingprocess, data processing includes, after an operating system of a firstdevice receives packets on a plurality of paths, each applicationrunning on the first device obtains, through only one system call, datathat is in data carried in the packets and that respectively correspondsto one or more applications. In the data sending process, dataprocessing includes each application running on the first devicedistributes data of the one or more applications to the paths throughonly one system call.

A connection may be at least one of an MP connection and a connection ofa single-path transmission technology.

An MP connection is a connection that includes a plurality of paths. Forexample, in this application, one end node of the MP connection is thefirst device, and the other end node is a second device. One or moreapplications run on the first device, and there is a one-to-one mappingrelationship between the MP connection and a socket descriptor (socket)of the application.

Connection of the single-path transmission technology: Compared with theMP connection, the connection of the single-path transmission technologyincludes only one path.

Path: The path is a link between a sender and a receiver. The path maybe identified by a 4-tuple or a 5-tuple. For example, the 5-tupleincludes a source Internet Protocol (IP) address, a source port number,a destination IP address, a destination port number, and a transportlayer protocol name. A plurality of paths between one receiver and onetransmitter may share one or more routers. The path in the embodimentsof this application includes a path in the MP connection and/or a pathin the connection of the single-path transmission technology. A streamtransmitted on the path may use a TCP, a UDP, a Stream ControlTransmission Protocol (SCTP), a QUIC, or the like.

The application runs on the first device, and there may be one or moreapplications. The one or more applications may perform data processingthrough only one system call. The application is, for example, alauncher, a media player, or a browser.

The system call means that the application performs context switchingonce, or may be understood as that the application performs trap-in andtrap-out once. For example, the operating system usually has two modes:a user mode and a kernel mode. The first device is used as an example.After the first device receives a packet, the packet does not directlyarrive at user space corresponding to the user mode, but is stored inkernel space corresponding to the kernel mode. The application needs totrap into the kernel mode of the operating system, read the packet fromthe kernel space to the user space, and then the application traps outto enter the user mode of the operating system. In a packet sendingprocess, the application also needs to trap into the kernel mode fromthe user mode, copy a to-be-sent packet from the user space to thekernel space, and then, the application traps out to enter the user modeof the operating system. For another example, when the operating systemof the first device does not distinguish context space, the first devicealso needs to execute the system call to process data.

A socket descriptor is a pointer and is an abbreviation of a socket filedescriptor. In the embodiments of this application, one path correspondsto one pair of socket descriptors that are respectively located at twoends of the path, and one socket descriptor indicates one segment ofcache space. For example, for a corresponding terminal, one socketindicator indicates a segment of cache space in kernel space of anoperating system of the terminal.

The following describes in detail the data processing method in theembodiments of this application on the basis of the foregoingarchitecture shown in FIG. 2.

FIG. 3 is a flowchart of a data processing method according to anembodiment of this application. In this embodiment, how an applicationrunning on a first device processes packets in a data receiving processafter the packets sent by a second device over a plurality of pathsarrive at the first device is described in detail. This embodimentincludes the following steps.

101: An operating system of the first device receives packets on theplurality of paths, where the packets are from the second device.

For example, one or more applications run in the operating system of thefirst device, a plurality of paths are established between the firstdevice and the second device, the plurality of paths include a path inan MP connection and/or a path in a connection of a single-pathtransmission technology, and the plurality of paths correspond to theone or more applications running in the operating system of the firstdevice. For example, referring to FIG. 2, the plurality of pathsincludes paths 1 to 6. The paths 1 to 4 are paths included by an MPconnection, the path 5 is a path in a connection of the single-pathtransmission technology, and the path 6 is a path in another connectionof the single-path transmission technology. An application 1 runs in theoperating system of the first device, and all the six paths correspondto the application 1. It should be understood that there may be anotherapplication in the first device, and the first device may alternativelybe an end node of another path, but the other path is not shown. Thatis, the plurality of paths may not be all paths maintained by the firstdevice. For another example, an application 1, an application 2, and anapplication 3 run in the operating system of the first device, the path1 and the path 2 correspond to the application 1, the path 3 and thepath 5 correspond to the application 2, and the path 4 and the path 6correspond to the application 3. Certainly, all the plurality of pathsmay be paths in a common single-path connection, that is, the paths 1 to6 each correspond to one application.

When sending the packets to the first device, the second device sendsthe packets to the first device over the foregoing plurality of paths.Correspondingly, the operating system of the first device receives thepackets. The foregoing example is still used. The second device sends apacket 1 to the first device over the path 1, sends a packet 2 and apacket 3 to the first device over the path 2, sends a packet 4, a packet5, and a packet 6 to the first device over the path 3, sends a packet 7to the first device over the path 4, sends a packet 8 to the firstdevice over the path 5, and sends a packet 9 to the first device overthe path 6. Correspondingly, the operating system of the first devicereceives the packets that pass through the paths.

102: After the operating system of the first device receives the packetson the plurality of paths, the one or more applications obtain, throughonly one system call, data respectively corresponding to the one or moreapplications from data carried in the packets.

For example, each path corresponds to one socket descriptor on thesecond device. The socket descriptor is essentially a pointer, and eachsocket descriptor may indicate one cache space. After receiving thepackets, an operating system of the second device stores the packets incache space indicated by socket descriptors of the paths. For example,the packet 1 is stored in storage space indicated by a socket descriptorof the path 1, the packet 2 and the packet 3 are stored in storage spaceindicated by a socket descriptor of the path 2, the packet 4, the packet5, and the packet 6 are stored in storage space corresponding to asocket descriptor of the path 4, . . . .

Then, the one or more applications execute only one system call, thatis, the application traps into a kernel mode, to obtain the datarespectively corresponding to the one or more applications from the datacarried in the packets. For example, each of the six paths correspondsto the application 1 running in the operating system of the firstdevice, and in this case, one system call is performed, and theapplication 1 obtains data from the packet 1 to the packet 9. Foranother example, the application 1, the application 2, and theapplication 3 run in the operating system of the first device, the path1 and the path 2 correspond to the application 1, the path 3 and thepath 5 correspond to the application 2, and the path 4 and the path 6correspond to the application 3, and in this case, the application 1,the application 2, and the application 3 execute one system call, theapplication 1 obtains data from the packet 1 to the packet 3, theapplication 2 obtains data from the packet 4, the packet 5, the packet6, and the packet 8, and the application 3 obtains data from the packet7 and the packet 9.

According to the data processing method provided in this embodiment ofthis application, the one or more applications run in the operatingsystem of the first device, there are the plurality of paths between thefirst device and the second device, and the plurality of pathscorrespond to the one or more applications running in the operatingsystem of the first device. After the operating system of the firstdevice receives the packets sent by the second device over the pluralityof paths, the one or more applications running in the operating systemof the first device obtain, through only one system call, the datarespectively corresponding to the one or more applications from the datacarried in the packets. In this process, the application running in theoperating system of the first device may obtain the data on theplurality of paths through only one system call, and may further obtain,for the plurality of paths, data in a plurality of packets (depending onan amount of data that is received by the plurality of paths in a kernelwhen the system call is being executed) from at least one path throughthe system call such that a quantity of system calls is small, andoverheads are small. Therefore, CPU utilization and power consumption ofthe first device can be reduced. In addition, because data in cachespace indicated by a plurality of socket descriptors can besimultaneously read through only one system call, data readingefficiency can be improved.

In the foregoing embodiment, to enable each application to determine,during the system call, a packet from which data is to be read, eachpacket from the second device carries an application identifier. In thiscase, when executing the system call, each application may determine apacket from which an application needs to read data. Alternatively, theoperating system of the first device pre-defines a correspondencebetween the path and the application, and maintains the correspondence.In this case, when executing the system call, each application maydetermine, based on the correspondence, a packet from which anapplication needs to read data.

In a feasible design, when the one or more applications obtain, throughonly one system call, the data respectively corresponding to the one ormore applications from the data carried in the packets, the one or moreapplications obtain, by calling a receive function only once, the datarespectively corresponding to the one or more applications from the datacarried in the packets. The receive function is a system call interface,and the receive function is used to poll socket descriptorscorresponding to two or more paths, to obtain data indicated by thesocket descriptors corresponding to the two or more paths.

For example, the one or more applications may bind socket descriptors ofthe plurality of paths together and transfer the socket descriptors tothe receive function as an array such that the receive function pollsthe socket descriptors in the array, to read the data in the packetsfrom cache space indicated by the socket descriptors. Certainly, inaddition to the array, another data structure may be used to enable thereceive function to learn the socket descriptors. For another example,the socket descriptors of the plurality of paths are sorted in advance,and the receive function reads, based on an order, data from the cachespace indicated by the socket descriptors.

For example, FIG. 4 is a flowchart of polling, by a receive function, asocket descriptor of each path in a data processing method according toan embodiment of this application. In this embodiment, the receivefunction is set to recvmmmsg( ), a total quantity of socket descriptorsis recorded as epcnt, and a current socket descriptor is an r^(th)socket descriptor. In a system calling process, data read by anapplication is stored in cache space of an application layer, and amaximum length of the cache space is vlen. This embodiment includes thefollowing steps.

201: Input parameters such as a socket descriptor of each path, thetotal quantity of socket descriptors, and the maximum length of thecache space of the application layer to the receive function.

202: Initialize r and l, where r is a number of a socket descriptorcurrently being traversed, and l is a length of currently read data.

203: Read data in cache space indicated by the r^(th) socket descriptor.

204: Determine whether r is less than the total quantity epcnt of socketdescriptors, and if r is less than the total quantity epcnt of socketdescriptors, perform step 205, or if r is greater than or equal to thetotal quantity of socket descriptors epcnt, perform step 208.

205: Determine whether l is less than the maximum length vlen of thecache space, and if l is less than the maximum length vlen of the cachespace, perform step 206, or if l is greater than or equal to the maximumlength vlen of the cache space, perform step 208.

206: Update 1 to 1+a, and then perform step 207, where a is a length ofthe data read in step 203.

207: Update r to r+1, and then perform step 203.

208: The receive function returns r.

In this embodiment, the one or more applications running in theoperating system of the first device manage each socket such that thereceive function polls the socket descriptors, to read the data in thepackets from cache space indicated by the socket descriptors.

In a feasible design, input of the receive function includes socketdescriptors respectively corresponding to the plurality of paths.

For example, when the one or more applications execute one system call,the one or more applications input the socket descriptors respectivelycorresponding to the plurality of paths to the receive function. Forexample, the socket descriptors respectively corresponding to theplurality of paths are bound as an array and input to the receivefunction. For another example, the one or more applications directlyinput the socket descriptors respectively corresponding to the pluralityof paths to the receive function.

During implementation, the one or more applications running in theoperating system of the first device input the socket descriptorsrespectively corresponding to the plurality of paths to the receivefunction such that the receive function polls the socket descriptors, toread the data in the packets from cache space indicated by the socketdescriptors.

In a feasible design, the one or more applications execute one systemcall to poll the socket descriptors respectively corresponding to theplurality of paths, and the operating system of the first device sendsfirst acknowledgement information to the one or more applications, wherethe first acknowledgement information indicates that the operatingsystem acknowledges that data respectively corresponding to the one ormore applications has been obtained by the one or more applications. Forexample, the one or more applications running in the operating system ofthe first device execute the system call to read data from cache spacecorresponding to a socket descriptor of each path, and the operatingsystem of the first device detects whether data in cache space indicatedby each socket descriptor has been successfully read, and generatesacknowledgment information for each socket descriptor. Acknowledgementinformation of all the socket descriptors forms the first acknowledgmentinformation. Acknowledgement information of each socket descriptor isused to indicate whether data in cache space indicated by the socketdescriptor has been successfully read.

In this embodiment, the operating system of the first device sends thefirst acknowledgment information to the one or more applications, andthe first acknowledgment information indicates that the operating systemdetermines whether the data respectively corresponding to the one ormore applications has been obtained by the one or more applications suchthat the operating system of the first device manages each application.

In a feasible design, at least two of the plurality of paths belong to asame multipath connection.

For example, still referring to FIG. 2, in the paths 1 to 6, the paths 1to 4 belong to a same multipath connection.

In this embodiment, because at least two of the plurality of pathsbelong to a same MP connection, in an MP connection implementationscenario, the application can read, through only one system call, datafrom cache space indicated by socket descriptors of a plurality of pathsincluded in the MP connection.

In a feasible design, the packets on the plurality of paths that arereceived by the operating system of the first device include at leasttwo packets from a same path.

For example, still referring to FIG. 2, the second device sends a packet1 to the first device over the path 1, sends a packet 2 and a packet 3to the first device over the path 2, sends a packet 4, a packet 5, and apacket 6 to the first device over the path 3, sends a packet 7 to thefirst device over the path 4, sends a packet 8 to the first device overthe path 5, and sends a packet 9 to the first device over the path 6.Correspondingly, the operating system of the first device receives thepackets that pass through the paths. The packet 2 and the packet 3 arefrom a same path, that is, the path 2, and the packet 4, the packet 5,and the packet 6 are from a same path, that is, the path 3.

In this embodiment, there may be a plurality of packets from a same pathsuch that when reading, through one system call, data from cache spaceindicated by the socket descriptors of the plurality of paths, theapplication can read data in at least two packets from cache spaceindicated by a same socket descriptor.

FIG. 5 is a schematic diagram of receiving data by an application in adata processing method according to an embodiment of this application.Referring to FIG. 5, in this embodiment, a first device is a firstdevice, a second device is a second device, a dotted-line box in thefigure shows an operating system of the first device, and an application1, an application 2, and an application 3 run in the operating system ofthe first device and respectively correspond to three paths. The threepaths each correspond to one socket descriptor on the first device: asocket descriptor 1 (S1), a socket descriptor 2 (S2), and a socketdescriptor 3 (S3). After a packet 1 sent by a server over the path 1arrives at the first device, the packet is received by the operatingsystem of the first device, and does not directly arrive at anapplication at an application layer, but is stored by the operatingsystem of the first device in cache space indicated by S1 below theapplication layer. Similarly, a packet 2 and a packet 3 that are sent bythe server over the path 2 arrive at the first device and are stored bythe operating system of the first device in cache space indicated by S2,and a packet 4 and a packet 5 that are sent by the server over the path3 arrive at the first device and are stored by the operating system ofthe first device in cache space indicated by S3.

Then, an application running in the operating system of the first deviceexecutes one system call to read the packet 1 to the packet 5 from cachespace indicated by respective socket descriptors of the path 1, the path2, and the path 3, to obtain data of the application.

FIG. 6 is a flowchart of another data processing method according to anembodiment of this application. In this embodiment, how an applicationrunning on a first device distributes, in a data sending process, datato be sent to a second device to a plurality of paths is described indetail. This embodiment includes the following steps.

301: One or more applications correspondingly distribute data of the oneor more applications to the plurality of paths through only one systemcall.

For example, one or more applications run in an operating system of thefirst device, a plurality of paths are established between the firstdevice and the second device, the plurality of paths include a path inan MP connection and/or a path in a connection of a single-pathtransmission technology, and the plurality of paths correspond to theone or more applications running in the operating system of the firstdevice. For example, referring to FIG. 2, the plurality of pathsincludes paths 1 to 6. The paths 1 to 4 are paths included by an MPconnection, the path 5 is a path in a connection of the single-pathtransmission technology, and the path 6 is a path in another connectionof the single-path transmission technology. An application 1 runs in theoperating system of the first device, and all the six paths correspondto the application 1. For another example, an application 1, anapplication 2, and an application 3 run in the operating system of thefirst device, the path 1 and the path 2 correspond to the application 1,the path 3 and the path 5 correspond to the application 2, and the path4 and the path 6 correspond to the application 3.

When sending data to the second device, the one or more applicationsrunning in the operating system of the first device first determines apath corresponding to each piece of to-be-sent data. Then, the one ormore applications write the data to storage space indicated by a socketdescriptor of each path through only one call. This process is alsoreferred to as correspondingly distributing the data to each path.

302: The operating system of the first device sends the data to thesecond device over the plurality of paths.

For example, the paths may transmit data based on a Wi-Fi network, acellular network, or BLUETOOTH. Therefore, the operating system of thefirst device may send data to the second device over a plurality ofpaths.

For example, referring to FIG. 2, the application 1 runs in theoperating system of the first device, and all the six paths correspondto the application 1. The application 1 determines to send a packet a tothe second device over the path 1, send a packet b and a packet c to thesecond device over the path 2, send a packet d, a packet e, and a packetf to the second device over the path 3, send a packet g to the seconddevice over the path 4, send a packet h to the second device over thepath 5, and send a packet i to the second device over the path 6.Through only one system call, the application 1 writes the packet a tocache space indicated by a socket descriptor of the path 1, writes thepacket b and the packet c to cache space indicated by a socketdescriptor of the path 2, writes the packet d, the packet e, and thepacket f to cache space indicated by a socket descriptor of the path 3,writes the packet g to cache space indicated by a socket descriptor ofthe path 4, writes the packet h to cache space indicated by a socketdescriptor of the path 5, and writes the packet i to cache spaceindicated by a socket descriptor of the path 6. Then, the operatingsystem of the first device sends the packet a to the packet i to thesecond device over the paths 1 to 6.

For another example, an application 1, an application 2, and anapplication 3 run in the operating system of the first device, the path1 and the path 2 correspond to the application 1, the path 3 and thepath 5 correspond to the application 2, and the path 4 and the path 6correspond to the application 3. The application 1 determines to send apacket a to the second device over the path 1, and send a packet b and apacket c to the second device over the path 2, the application 2determines to send a packet d, a packet e, and a packet f to the seconddevice over the path 3, and send a packet h to the second device overthe path 5, and the application 3 determines to send a packet g to thesecond device over the path 4, and send the packet i to the seconddevice over the path 6. Through only one system call, the application 1,the application 2, and the application 3 write the packet a to cachespace indicated by a socket descriptor of the path 1, write the packet band the packet c to cache space indicated by a socket descriptor of thepath 2, write the packet d, the packet e, and the packet f to cachespace indicated by a socket descriptor of the path 3, write the packet gto cache space indicated by a socket descriptor of the path 4, write thepacket h to cache space indicated by a socket descriptor of the path 5,and write the packet i to cache space indicated by a socket descriptorof the path 6. Then, the operating system of the first device sends thepacket a to the packet i to the second device over the paths 1 to 6.

According to the data processing method provided in this embodiment ofthis application, the one or more applications run in the operatingsystem of the first device, there are the plurality of paths between thefirst device and the second device, and the plurality of pathscorrespond to the one or more applications running in the operatingsystem of the first device. The one or more applications running in theoperating system of the first device correspondingly distribute the dataof the one or more applications to the plurality of paths through onlyone system call, and then, the operating system of the first devicesends the data to the second device over the plurality of paths. In thisprocess, the one or more applications running in the operating system ofthe first device may distribute the data of the one or more applicationsto corresponding paths through only one system call such that a quantityof system calls is small, and overheads are small. Therefore, CPUutilization and power consumption of the first device can be reduced. Inaddition, because data can be simultaneously written, through only onesystem call, to cache space indicated by a plurality of socketdescriptors, data writing efficiency can be improved.

In the foregoing embodiment, in a data sending process, same data may besent on different paths. For example, an application 1 runs in theoperating system of the first device, the application 1 is to send data1, data 2, and data 3 to the second device, and the applicationcorresponds to the path 1, the path 2, and the path 3. Through only onesystem call, the application 1 distributes the data 1 and the data 2 tothe path 1, distributes the data 3 to the path 2, and distributes thedata 1, the data 2, and the data 3 to the path 3, to send same data ondifferent paths.

In a feasible design, that the one or more applications correspondinglydistribute data of the one or more applications to the plurality ofpaths through only one system call includes correspondinglydistributing, by the one or more applications, the data of the one ormore applications to the plurality of paths by calling a transmitfunction only once, where the transmit function is a system callinterface, and the transmit function is used to poll socket descriptorscorresponding to two or more paths, to distribute the data to cachespace indicated by the socket descriptors corresponding to the two ormore paths.

For example, the one or more applications may bind socket descriptors ofthe plurality of paths together and transfer the socket descriptors tothe transmit function as an array such that the transmit function pollsthe socket descriptors in the array, to write the data to the cachespace indicated by the socket descriptors. For another example, thesocket descriptors of the plurality of paths are sorted in advance, andthe transmit function writes, based on an order, the data of the one ormore applications to the cache space indicated by the socketdescriptors.

In this embodiment, the one or more applications running in theoperating system of the first device manage each socket such that thetransmit function polls the socket descriptors, to write the data of theone or more applications to cache space indicated by the socketdescriptors.

In a feasible design, input of the transmit function includes socketdescriptors respectively corresponding to the plurality of paths.

For example, when the one or more applications execute one system call,the one or more applications input the socket descriptors respectivelycorresponding to the plurality of paths to the transmit function. Forexample, the socket descriptors respectively corresponding to theplurality of paths are bound as an array and input to the transmitfunction. For another example, the one or more applications directlyinput the socket descriptors respectively corresponding to the pluralityof paths to the transmit function.

During implementation, the one or more applications running in theoperating system of the first device input the socket descriptorsrespectively corresponding to the plurality of paths to the transmitfunction such that the transmit function polls the socket descriptors,to write the data of the one or more applications to cache spaceindicated by the socket descriptors.

In a feasible design, the one or more applications execute one systemcall, and poll the socket descriptors respectively corresponding to theplurality of paths, to write the data to the cache space indicated bythe socket descriptors. The operating system of the first device sendssecond acknowledgment information to the one or more applications, wherethe second acknowledgment information indicates that the operatingsystem acknowledges that the data respectively corresponding to the oneor more applications has been written to the cache space indicated bythe socket descriptors respectively corresponding to the plurality ofpaths. For example, the one or more applications running in theoperating system of the first device execute the system call to writethe data of the one or more applications to the cache spacecorresponding to the socket descriptors of the paths, and the operatingsystem of the first device detects whether data has been written tocache space indicated by each socket descriptor, and generatesacknowledgment information for each socket descriptor. Acknowledgementinformation of all the socket descriptors forms the secondacknowledgment information. Acknowledgement information of each socketis used to indicate whether data has been written to cache spaceindicated by the socket descriptor.

In this embodiment, the operating system of the first device sends thesecond acknowledgment information to the one or more applications, andthe second acknowledgment information indicates that the operatingsystem determines whether the data respectively corresponding to the oneor more applications has been distributed to the paths such that theoperating system of the first device manages each application.

In a feasible design, at least two of the plurality of paths belong to asame multipath connection.

For example, still referring to FIG. 2, in the paths 1 to 6, the paths 1to 4 belong to a same multipath connection.

In this embodiment, because at least two of the plurality of pathsbelong to a same MP connection, in an MP connection implementationscenario, the application can write, through only one system call, datato cache space indicated by socket descriptors of a plurality of pathsincluded in the MP connection.

FIG. 7 is a schematic structural diagram of a data processing apparatus100 according to an embodiment of this application. The apparatus isconfigured to process data on a plurality of paths, the plurality ofpaths are paths between a first device and a second device, theplurality of paths corresponds to one or more applications, the one ormore applications run in an operating system of the first device, andthe apparatus 100 includes an operating system 11 and an application 12.When the data processing apparatus 100 is configured to process data ina data receiving process, functions of the operating system 11 and theapplication 12 are as follows.

The operating system 11 is configured to receive packets on theplurality of paths, where the packets are from the second device.

The application 12 is configured to, after the operating system 11receives the packets on the plurality of paths, obtain, through only onesystem call, data respectively corresponding to the one or moreapplications from data carried in the packets.

In a feasible design, the application 12 is configured to obtain, bycalling a receive function only once, the data respectivelycorresponding to the one or more applications from the data carried inthe packets, where the receive function is a system call interface, andthe receive function is used to poll socket descriptors corresponding totwo or more paths, to obtain data indicated by the socket descriptorscorresponding to the two or more paths.

In a feasible design, input of the receive function includes socketdescriptors respectively corresponding to the plurality of paths.

In a feasible design, the operating system 11 is further configured tosend first acknowledgment information to the one or more applications,where the first acknowledgment information indicates that the operatingsystem acknowledges that the data respectively corresponding to the oneor more applications has been obtained by the one or more applications.

In a feasible design, at least two of the plurality of paths belong to asame multipath connection.

In a feasible design, the packets on the plurality of paths that arereceived by the operating system of the first device include at leasttwo packets from a same path.

When the data processing apparatus 100 is configured to process data inthe data receiving process, functions of the operating system 11 and theapplication 12 are as follows.

The application 12 is configured to correspondingly distribute data ofthe one or more applications to the plurality of paths through only onesystem call.

The application system 11 is configured to send the data to the seconddevice over the plurality of paths.

In a feasible design, the application 12 is configured tocorrespondingly distribute the respective data of the one or moreapplications to the plurality of paths by calling a transmit functiononly once, where the transmit function is a system call interface, andthe transmit function is used to poll socket descriptors correspondingto two or more paths, to distribute the data to cache space indicated bythe socket descriptors corresponding to the two or more paths.

In a feasible design, input of the transmit function includes socketdescriptors respectively corresponding to the plurality of paths.

In a feasible design, the operating system 11 is further configured tosend second acknowledgment information to the one or more applications,where the second acknowledgment information indicates that the operatingsystem acknowledges that the data respectively corresponding to the oneor more applications has been written to cache space indicated by thesocket descriptors respectively corresponding to the plurality of paths.

In a feasible design, at least two of the plurality of paths belong to asame multipath connection.

FIG. 8 is a schematic structural diagram of a data processing apparatus200 according to an embodiment of this application. As shown in FIG. 8,the data processing apparatus 200 may include a processor 21 (forexample, a CPU) and a memory 22. The memory 22 may include a high-speedrandom-access memory (RAM), and may further include a non-volatilememory (NVM) such as at least one disk memory. The memory 24 may storevarious instructions, to complete various processing functions andimplement the method steps of this application.

Optionally, the data processing apparatus involved in this applicationmay further include a communications bus 23 and a communicationsinterface 24. The communications bus 23 is configured to implement acommunication connection between elements, and the communicationsinterface 24 is configured to implement connection and communicationbetween the data processing apparatus and another peripheral device.

In this embodiment of this application, after each application isdownloaded to a first device, an installation package of the applicationis stored in the memory 22. When the application is installed, theprocessor 21 processes the installation package stored in the memory 22such that the application runs in an operating system of the firstdevice. Alternatively, the application is an application included in theoperating system, and can run in the operating system without beingdownloaded and installed. The operating system of the first device isstored in the memory 22. The operating system drives hardware using aninstruction set of the hardware. The memory 22 is further configured tostore computer executable program code, and the program code includes aninstruction. When the processor 21 executes an instruction, theinstruction enables the processor 21 of the data processing apparatus toexecute a processing action of the first device in the foregoingembodiment or an optional embodiment. Implementation principles andtechnical effects of the instruction are similar to the foregoingdescriptions, and details are not described herein again.

An embodiment of this application further provides a storage medium, thestorage medium stores a computer execution instruction, and the computerexecution instruction is used to implement the foregoing data processingmethod when being executed by a processor.

An embodiment of the present disclosure further provides a computerprogram product. When the computer program product runs on a firstdevice, the first device is enabled to perform the foregoing dataprocessing method.

A person skilled in the art should easily be aware that, in combinationwith the examples described in the embodiments disclosed in thisspecification, algorithms steps may be implemented by hardware or acombination of hardware and computer software. Whether a function isperformed by hardware or hardware driven by computer software depends onparticular applications and design constraints of the technicalsolutions. A person skilled in the art may use different methods toimplement the described functions for each particular application, butit should not be considered that the implementation goes beyond thescope of this application.

In the embodiments of this application, the first device may be dividedinto functional modules based on the foregoing method examples. Forexample, each functional module corresponding to each function may beobtained through division, or two or more functions may be integratedinto one processing module. The integrated module may be implemented ina form of hardware, or may be implemented in a form of a softwarefunctional module. It should be noted that, in the embodiments of thisapplication, division into the modules is an example, is merely logicalfunction division, and may be other division in actual implementation.

The term “a plurality of” in this specification means two or more. Theterm “and/or” in this specification describes only an associationrelationship for describing associated objects and represents that threerelationships may exist. For example, A and/or B may represent thefollowing three cases: only A exists, both A and B exist, and only Bexists. In addition, the character “/” in this specification generallyindicates that associated objects are in an “or” relationship. In aformula, the character “/” indicates that associated objects are in a“division” relationship.

It may be understood that various reference numerals in the embodimentsof this application are merely descriptions for convenientdifferentiation, and are not used to limit the scope of the embodimentsof this application.

It may be understood that sequence numbers of the foregoing processes donot mean an execution sequence in the embodiments of this application.The execution sequence of the processes should be determined based onfunctions and internal logic of the processes, and should not beconstrued as any limitation on the implementation processes of theembodiments of this application.

It may be understood that in the embodiments of this application, thememory may be a non-volatile memory, such as a hard disk drive (HDD) ora solid-state drive (SSD), or may be a volatile memory, such as a RAM.The memory is any other medium that can be used to carry or storeexpected program code in a form of an instruction or a data structureand that can be accessed by a computer, but is not limited thereto. Thememory in the embodiments of this application may be a circuit or anyother apparatus that can implement a storage function, and is configuredto store a program instruction and/or data.

The foregoing descriptions of implementations allow a person skilled inthe art to understand that, for convenient and brief description,division into the foregoing functional modules is used as an example forillustration. In actual application, the foregoing functions may beallocated to and implemented by different functional modules based on arequirement. That is, an inner structure of an apparatus is divided intodifferent functional modules to implement all or some of the functionsdescribed above.

In the several embodiments provided in this application, it should beunderstood that the disclosed apparatus and method may be implemented inother manners. For example, the described apparatus embodiments areexamples. For example, division into the modules or units is merelylogical function division and may be other division in actualimplementation. For example, a plurality of units or components may becombined or integrated into another apparatus, or some features may beignored or not performed. In addition, the displayed or discussed mutualcouplings or direct couplings or communication connections may beimplemented by some interfaces. The indirect couplings or communicationconnections between the apparatuses or units may be implemented inelectrical, mechanical, or other forms.

The units described as separate parts may or may not be physicallyseparate, and parts displayed as units may be one or more physicalunits, may be located in one place, or may be distributed on differentplaces. Some or all of the units may be selected based on actualrequirements to achieve the objectives of the solutions of theembodiments.

In addition, functional units in the embodiments of this application maybe integrated into one processing unit, or each of the units may existalone physically, or two or more units are integrated into one unit. Theintegrated unit may be implemented in a form of hardware, or may beimplemented in a form of a software functional unit.

All or some of the foregoing methods in the embodiments of thisapplication may be implemented by software, hardware, firmware, or anycombination thereof. When software is used to implement the embodiments,some or all of the embodiments may be implemented in a form of acomputer program product. The computer program product includes one ormore computer instructions. When the computer program instructions areloaded and executed on a computer, all or some of the procedures orfunctions according to the embodiments of this application aregenerated. The computer may be a general-purpose computer, a dedicatedcomputer, a computer network, a first device, a terminal, or anotherprogrammable apparatus. The computer instructions may be stored in acomputer-readable storage medium or may be transmitted from acomputer-readable storage medium to another computer-readable storagemedium. For example, the computer instructions may be transmitted from awebsite, computer, server, or data center to another website, computer,server, or data center in a wired (for example, a coaxial cable, anoptical fiber, or a digital subscriber line (DSL)) or wireless (forexample, infrared, radio, or microwave) manner. The computer-readablestorage medium may be any usable medium accessible by a computer, or adata storage device, such as a server or a data center, integrating oneor more usable media. The usable medium may be a magnetic medium (forexample, a floppy disk, a hard disk, or a magnetic tape), an opticalmedium (for example, a digital video disc (DVD)), a semiconductor medium(for example, an SSD), or the like.

The foregoing descriptions are merely specific implementations of thisapplication, but are not intended to limit the protection scope of thisapplication. Any variation or replacement within the technical scopedisclosed in this application shall fall within the protection scope ofthis application. Therefore, the protection scope of this applicationshall be subject to the protection scope of the claims.

What is claimed is:
 1. A data processing method comprising: receiving,by an operating system of a first device and from a second device,packets on a plurality of paths between the first device and the seconddevice, wherein the paths correspond to one or more applications run inthe operating system; and obtaining, by the one or more applicationsthrough a system call, first data corresponding to the one or moreapplications from second data carried in the packets.
 2. The dataprocessing method of claim 1, further comprising obtaining, by the oneor more applications by calling a receive function, the first data,wherein the receive function is a system call interface that polls firstsocket descriptors corresponding to two or more paths to obtain thirddata indicated by the first socket descriptors.
 3. The data processingmethod of claim 2, wherein a first input of the receive functioncomprises second socket descriptors corresponding to the paths.
 4. Thedata processing method of claim 3, wherein a second input of the receivefunction comprises a total quantity of the second socket descriptors. 5.The data processing method of claim 1, further comprising sending, bythe operating system, first acknowledgment information to the one ormore applications, wherein the first acknowledgment informationindicates that the operating system acknowledges that the first data hasbeen obtained by the one or more applications.
 6. The data processingmethod of claim 1, wherein at least two of the paths belong to a samemultipath connection.
 7. The data processing method of claim 1, whereinthe packets comprise at least two packets from a same path.
 8. A dataprocessing method comprising: distributing, by one or more applications,data of the one or more applications to a plurality of paths through asystem call, wherein the paths correspond to the one or moreapplications and are located between a first device and a second device,and wherein the one or more applications run in an operating system ofthe first device; and sending, by the operating system, the data to thesecond device over the paths.
 9. The data processing method of claim 8,further comprising distributing, by the one or more applications, thedata to the paths by calling a transmit function, wherein the transmitfunction is a system call interface that polls first socket descriptorscorresponding to two or more paths to distribute the data to a cachespace indicated by the first socket descriptors.
 10. The data processingmethod of claim 9, wherein a first input of the transmit functioncomprises second socket descriptors corresponding to the paths.
 11. Thedata processing method of claim 10, wherein a second input of thetransmit function comprises a total quantity of the second socketdescriptors.
 12. The data processing method of claim 10, furthercomprising sending, by the operating system, acknowledgment informationto the one or more applications, wherein the acknowledgment informationindicates that the operating system acknowledges that the datacorresponding to the one or more applications has been written to asecond cache space indicated by the second socket descriptors.
 13. Thedata processing method of claim 8, wherein at least two paths belong toa same multipath connection.
 14. A first terminal device comprising: amemory configured to store instructions; and a processor coupled to thememory, wherein the instructions cause the processor to be configuredto: receive, using an operating system of the first terminal device froma second terminal device, packets on a plurality of paths; and obtain,using one or more applications through a system call, first datacorresponding to the one or more applications from second data carriedin the packets.
 15. The first terminal device of claim 14, wherein theinstructions further cause the processor to be configured to obtain,using the one or more applications by calling a receive function, thefirst data, wherein the receive function is a system call interface thatpolls first socket descriptors corresponding to two or more paths toobtain third data indicated by the first socket descriptors.
 16. Thefirst terminal device of claim 15, wherein a first input of the receivefunction comprises second socket descriptors corresponding to the paths.17. The first terminal device of claim 16, wherein a second input of thereceive function comprises a total quantity of the second socketdescriptors.
 18. The first terminal device of claim 14, wherein theinstructions further cause the processor to be configured to send, usingthe operating system, first acknowledgment information to the one ormore applications, wherein the first acknowledgment informationindicates that the operating system acknowledges that the first data hasbeen obtained by the one or more applications.
 19. The first terminaldevice of claim 14, wherein at least two of the paths belong to a samemultipath connection.
 20. The first terminal device of claim 14, whereinthe packets comprise at least two packets from a same path.